package com.softer.chengxin.syshome.controller;


import com.softer.chengxin.syshome.entity.SysModule;
import com.softer.chengxin.syshome.service.SysHomeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @author Gong Zhiyang
 * @date 2018/9/26
 */
@RestController
@RequestMapping("/api/sysHome")
@Slf4j
public class SysHomeController {
    @Autowired
    private SysHomeService homeService;

    /**
     * 获取菜单
     *
     * @param session 缓存
     * @return 菜单列表
     */
    @RequestMapping ("/GetMenu")
    public List<SysModule> GetMenu(HttpSession session) {
        //登陆用户名
        String loginName = (String) session.getAttribute("loginName");
        //登陆类型
        String loginType = (String) session.getAttribute("loginType");
        //获取项目ID
        String projectId = (String) session.getAttribute("projectId");
        log.info("获取菜单开始！loginName："+loginName);
        List<SysModule> sysModules = homeService.selectAll(loginName, loginType, projectId);
        log.info("获取菜单结束！sysModules.size："+sysModules.size());
        return sysModules;
    }

}
